package org.jsola.hr.helper;

import org.jsola.hr.constant.EmpInfoRequireType;
import org.jsola.hr.constant.EmpInfoScene;
import org.jsola.hr.dto.EmpCertificateRequireAddDTO;
import org.jsola.hr.dto.EmpCertificateRequireUpdateDTO;
import org.jsola.hr.entity.EmpCertificateRequireDO;
import org.jsola.hr.query.EmpCertificateRequireQuery;
import org.jsola.hr.service.IEmpCertificateRequireService;
import org.jsola.hr.vo.EmpCertificateRequireVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * @author zhr
 */
@Component
public class EmpCertificateRequireTestHelper extends BaseTestHelper {
    
    @Autowired
    private IEmpCertificateRequireService empCertificateRequireService;

    /**
     * 生成add测试数据
     * @return EmpCertificateRequireAddDTO
     */
    public EmpCertificateRequireAddDTO getEmpCertificateRequireAddDTO(){
        EmpCertificateRequireAddDTO empCertificateRequireAddDTO = new EmpCertificateRequireAddDTO();
        empCertificateRequireAddDTO.setCompanyId(EmpInfoScene.ENTRY.getValue());
        empCertificateRequireAddDTO.setRequireType(EmpInfoScene.ENTRY.getValue());
        empCertificateRequireAddDTO.setType(EmpInfoRequireType.NO_NEED.getValue());
        empCertificateRequireAddDTO.setName(EmpInfoRequireType.NO_NEED.getValue());
        empCertificateRequireAddDTO.setLevel(EmpInfoRequireType.NO_NEED.getValue());
        empCertificateRequireAddDTO.setNumber(EmpInfoRequireType.NO_NEED.getValue());
        empCertificateRequireAddDTO.setStartTime(EmpInfoRequireType.NO_NEED.getValue());
        empCertificateRequireAddDTO.setEndTime(EmpInfoRequireType.NO_NEED.getValue());
        empCertificateRequireAddDTO.setRemark(EmpInfoRequireType.NO_NEED.getValue());
        return empCertificateRequireAddDTO;
    }


    /**
     * 生成update测试数据
     * @return EmpCertificateRequireUpdateDTO
     */
    public EmpCertificateRequireUpdateDTO getEmpCertificateRequireUpdateDTO(EmpCertificateRequireVO empCertificateRequireVO){
        return empCertificateRequireService.selectDOById(empCertificateRequireVO.getId(), SITE_ID).to(EmpCertificateRequireUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return EmpCertificateRequireQuery
     */
    public EmpCertificateRequireQuery getEmpCertificateRequireQuery() {
        EmpCertificateRequireQuery empCertificateRequireQuery = new EmpCertificateRequireQuery();
        List<EmpCertificateRequireDO> empCertificateRequireDOList = empCertificateRequireService.list(new EmpCertificateRequireDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(empCertificateRequireDOList)) {
            EmpCertificateRequireDO empCertificateRequireDO = empCertificateRequireDOList.get(0);
            empCertificateRequireQuery = empCertificateRequireDO.to(EmpCertificateRequireQuery.class);
        }
        return empCertificateRequireQuery;
    }

    /**
     * 保存示例
     * @return EmpCertificateRequireVO
     */
    public EmpCertificateRequireVO saveEmpCertificateRequireExample(){
        EmpCertificateRequireAddDTO addDTO = this.getEmpCertificateRequireAddDTO();
        EmpCertificateRequireVO empCertificateRequireVO = empCertificateRequireService.save(addDTO,buildTokenUser());
        return empCertificateRequireVO;
    }


}

